package face.array;

/**
 * @author spf
 * @date 2024/8/21
 * @time 17:03
 */

import java.util.Scanner;

/**
 * 区间和
 */
public class QuJianHe {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];

        int[] pres = new int[n];
        int pre = 0;
        for(int i=0; i<n; i++){
            nums[i] = scanner.nextInt();
            pre += nums[i];
            pres[i] = pre;
        }

        while (scanner.hasNextInt()){
            int start = scanner.nextInt();
            int end = scanner.nextInt();

            int sum = 0;
            if (start == 0){
                sum = pres[end];
            }else{
                sum = pres[end] - pres[start - 1];
            }
            System.out.println(sum);
        }
        scanner.close();
    }
}
